﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Password_Generator
{
    class GenerateViewModel : INotifyPropertyChanged
    {
        Generator _generate;
        Misc _misc;


        public GenerateViewModel()
        {
            _generate = new Generator();
            _misc = new Misc();   
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string property)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(property));

            }

        }


#region Commands
        private bool CanExecute()
        {
            return true;
        }

        private void Close()
        {
            Application.Current.Shutdown();
        }
        private void AboutWindow()
        {
           About _about = new About();
            _about.Show();
            

        }

        private void About()
        {
            About about = new About();
            about.Show();
            

        }

        public ICommand LaunchAbout
        {
            get
            {
                return new Command(CanExecute, About);
            }
        }

        public ICommand ExitProgram
        {
            get
            {
                return new Command(CanExecute, Close);
            }
        }


        //The generator class needs to be finished first.
       public ICommand GeneratePassword { 
            get 
            { 
                return new Command(CanExecute, Close); 
            } 
        }

#endregion



#region Properties

        public Generator Generate 
     { 
         get
         {
             return _generate;
         }
         set
         {
             _generate = value;
         }
     }

        public Misc Misc
        {
            get
            {
                return _misc;
            }
            set
            {
                _misc = value;
            }

        }


        public bool Letters
        {
            get
            {
                return Generate.Letters;
            }
            set
            {
                Generate.Letters = value;

            }

        }

        public bool Numbers
        {
            get { return Generate.Numbers; }
            set
            {
                Generate.Numbers = value;
                OnPropertyChanged("Numbers");

            }
        }

        public bool Symbols
        {
            get { return Generate.Symbols; }
            set
            {
                Symbols = value;
                OnPropertyChanged("Symbols");

            }
        }


        public bool Clip
        {
            get { return Generate.Clip; }
            set
            {
                Generate.Clip = value;
                OnPropertyChanged("Clip");
            }

        }

        public int Limit
        {
            get { return Generate.Limit; }
            set
            {
                Generate.Limit = value;
                OnPropertyChanged("Limit");

            }
        }


        public string Title
        {
            get { return Misc.Title; }
        }

        public string Devs
        {
            get { return Misc.Devs; }
        }

    }
        #endregion


}
